package com.spring.aop.annotation;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@org.aspectj.lang.annotation.Aspect

public class Aspect {
	
	@Before(value="execution(*   com.spring.aop.annotation.OrderDao.save(..))")
	public  void  before() {
		System.out.println("=======我是切面，我来也  ，前置增强============");
	}
  
	
	@AfterReturning(value="execution( * com.spring.aop.annotation.OrderDao.delete(..))",returning="result")
	public void afterReturning(Object result) {
		System.out.println("后置增强--------"+result);
	}
	
	@Around(value="execution( * com.spring.aop.annotation.OrderDao.update(..))")
	public  Object   around(ProceedingJoinPoint joinPoint) throws Throwable {
		System.out.println("我是前环绕通知=========");
	    joinPoint .proceed(); 
		System.out.println("我是后环绕通知=========");
		return joinPoint;
	}
	

	@AfterThrowing(value="execution( * com.spring.aop.annotation.OrderDao.find(..))",throwing="ex")
      public void AfterThrowing(Throwable ex) {
		System.out.println("我是异常抛出======="+ex);
	}
	
	@After(value="execution( * com.spring.aop.annotation.OrderDao.find(..))")
	public  void after() {
		System.out.println("--------我是最终通知------");
	}
	
	
	
	
//				@Pointcut(value="execution(*   com.spring.aop.annotation.OrderDao.save(..))")
//				private void pointcut1() {  }
//				@Pointcut(value="execution(*   com.spring.aop.annotation.OrderDao.find(..))")
//				private void pointcut2() {  }
//				@Pointcut(value="execution(*   com.spring.aop.annotation.OrderDao.update(..))")
//				private void pointcut3() {  }
//				@Pointcut(value="execution(*   com.spring.aop.annotation.OrderDao.delete(..))")
//				private void pointcut4() {  }
//				
//				
//				@Before(value="Aspect.pointcut1()")
//				public void bef() {
//					System.out.println("hhhhhhhh====前置通知");
//				}
//				
	
}
